package payment

import "fmt"

type AliPay struct {
	Config
	AppID string //支付宝特有字段
}

func NewAliPay(config Config, appID string) *AliPay {
	return &AliPay{
		Config: config,
		AppID:  appID,
	}
}

func (a *AliPay) Pay(amount float64) (string, error) {
	//模拟支付宝支付调用
	url := fmt.Sprintf("https://api.alipay.com/pay?amount=%.2f&mid=%s", amount, a.MerchantID)
	return fmt.Sprintf("支付宝支付成功[订单，%s][沙箱模式：%v]", url, a.IsSandbox), nil

}
func (a *AliPay) Refund(orderID string) (string, error) {
	//模拟退款逻辑
	return fmt.Sprintf("支付宝退款成功[订单：%s][密钥：%s]", orderID, a.SecretKey[:3]+"***"), nil
}
